<template>
  <div class="border-line card">
    <header-title title="补贴发放情况（元）" @fullScreen="handleFullScreen"></header-title>
    <div class="card-content">
      <div class="table">
        <div class="header">
          <div class="col">区级名称</div>
          <div class="col">一季度</div>
          <div class="col">二季度</div>
          <div class="col">三季度</div>
          <div class="col">四季度</div>
        </div>
        <vue-seamless-scroll :data="listData" :class-option="classOption" class="scroll-warp">
          <ul class="item">
            <li v-for="(item, index) in listData" :key="index">
              <span class="col">
                <template v-if="isFullscren && areaID !== 0">
                  <ellipsis :length="22">{{ item.name }}</ellipsis>
                </template>
                <template v-else>
                  <a-tooltip :title="item.name">
                    <span>{{ item.simname }}</span>
                  </a-tooltip>
                </template>
              </span>
              <span class="col">{{ item.JDONE }}</span>
              <span class="col">{{ item.JDTWO }}</span>
              <span class="col">{{ item.JDTHREE }}</span>
              <span class="col">{{ item.JDFOUR }}</span>
            </li>
          </ul>
        </vue-seamless-scroll>
      </div>
    </div>
  </div>
</template>

<script>
import headerTitle from './headerTitle.vue'
import vueSeamlessScroll from 'vue-seamless-scroll'
import { Ellipsis } from '@/components'
import { getDistributionStatus } from '@/api/analysis'
export default {
  props: {
    areaID: {
      type: Number,
      default: 0
    },
    isFullscren: {
      type: Boolean,
      default: false
    }
  },
  components: {
    vueSeamlessScroll,
    Ellipsis,
    headerTitle
  },
  data () {
    return {
      classOption: {
        singleHeight: 40
      },
      listData: [],
      titleFontSize: 24,
      fontSize: 16
    }
  },
  mounted () {
    this.fetchData()
  },
  watch: {
    areaID: function (newVal, oldVal) {
      this.fetchData()
    }
  },
  methods: {
    fetchData () {
      getDistributionStatus({ RegionNo: this.areaID }).then(res => {
        this.listData = res
      })
    },
    beforeDestoryed () {
      window.removeEventListener('resize')
    },
    handleFullScreen () {
      this.$emit('fullScreen')
    }
  }
}
</script>
<style lang="less" scoped>
.card {
  height: 400px;
  width: 100%;
  &-content {
    margin-top: 20px;
    cursor: default;
  }
  .count {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    &-item {
      flex: 1;
      border-left: 4px solid #07d6de;
      font-size: 16px;
      padding-left: 10px;

      .num {
        font-size: 24px;
        color: #ffc600;
      }
      .unit {
        color: #64d1e4;
        margin-left: 10px;
      }
    }
  }
  .table {
    .col {
      flex: 1;
    }

    .header {
      background: #0f3560;
      font-size: 16px;
      padding: 0 18px;
      color: #fff;
      display: flex;
      justify-content: space-between;
      height: 40px;
      line-height: 40px;
    }

    .scroll-warp {
      height: 280px;
      width: 100%;
      margin: 0 auto;
      overflow: hidden;
      ul {
        list-style: none;
        padding: 0;
        margin: 0 auto;
        li {
          height: 40px;
          line-height: 40px;
          padding: 0 18px;
          color: #61a8ff;
          position: relative;
          font-size: 14px;
          display: flex;
          justify-content: space-between;
          &:nth-child(2n) {
            background: rgb(8, 38, 91);
          }
        }
      }
    }
  }
}
</style>
